package org.ccams.dao;

import java.util.List;

import org.ccams.domain.TPricelist;
import org.ccams.util.PageParameter;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class TPricelistDAO extends SqlMapClientDaoSupport {

	public TPricelistDAO() {
		super();
	}

	public void insert(TPricelist record) {
		getSqlMapClientTemplate().insert("t_pricelist.abatorgenerated_insert",
				record);
	}

	public int updateByPrimaryKey(TPricelist record) {
		int rows = getSqlMapClientTemplate().update(
				"t_pricelist.abatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	public int updateByPrimaryKeySelective(TPricelist record) {
		int rows = getSqlMapClientTemplate().update(
				"t_pricelist.abatorgenerated_updateByPrimaryKeySelective",
				record);
		return rows;
	}

	public TPricelist selectByPrimaryKey(Long idtPricelist) {
		TPricelist key = new TPricelist();
		key.setIdtPricelist(idtPricelist);
		TPricelist record = (TPricelist) getSqlMapClientTemplate()
				.queryForObject(
						"t_pricelist.abatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	public int deleteByPrimaryKey(Long idtPricelist) {
		TPricelist key = new TPricelist();
		key.setIdtPricelist(idtPricelist);
		int rows = getSqlMapClientTemplate().delete(
				"t_pricelist.abatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	@SuppressWarnings("unchecked")
	public List<TPricelist> getByPage(PageParameter page) {
		return getSqlMapClientTemplate().queryForList("t_pricelist.getByPage", page);
	}

	/**
	 * 返回记录总数
	 * @return
	 */
	public int getCount() {
		return (Integer) getSqlMapClientTemplate().queryForObject(
				"t_pricelist.getCount");
	}

	/**
	 * 返回所有
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<TPricelist> getAll() {
		return getSqlMapClientTemplate().queryForList("t_pricelist.getAll");
	}
}